// 全局请求拦截响应
const request = (url,Method,data)=>{
	let options = {
		url:`http://ldxinglou.xundong.top${url}`,
		method:Method,
		header:{
			"Authorization": 'Bearer '
		},
		data
	}
	
	let promise = new Promise((resolve, reject)=> {
		uni.request(options).then(
			res => {
				if(res[1].data.code == 0 || res[1].data.code == 500 || !res[1].data){
					resolve(res[1])
				}else{
					console.log(res)
					uni.showToast({
						icon:'none',
						title: '网络错误',
						duration: 2000 
					}); 
					return false
				}
			}
		).catch(
			(response) => {
				reject(response)
			}
		)
	})
	return promise	
}

export default request